package org.gd.hellojaxb.privat24.document;

import org.gd.hellojaxb.utils.MarshallProperties;
import org.gd.hellojaxb.utils.Marshall;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;

/*
sb.append("<request baseUrl=\"").append(getAppPath(req))
				.append("\" url=\"").append(getAppURL(req))
				.append("\" os=\"").append(getBrowserDetection(req, user).getPlatform())
				.append("\" win=\"").append(getBrowserDetection(req, user).isWin() ? "Y" : "N")
				.append("\" ie=\"").append(getBrowserDetection(req, user).isMsie() ? "Y" : "N")
				.append("\"/>");
*/

@XmlRootElement(name = "request")
@XmlAccessorType(XmlAccessType.FIELD)
public class HeaderRequest {

    @XmlAttribute(name = "url_base")
    private String baseUrl;
    @XmlAttribute(name = "url")
    private String url;
    @XmlAttribute(name = "os")
    private String os;
    @XmlAttribute(name = "win")
    private String win;
    @XmlAttribute(name = "ie")
    private String ie;

    public HeaderRequest() {
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public HeaderRequest setBaseUrl(String baseUrl) {
        this.baseUrl = baseUrl;
        return this;
    }

    public String getUrl() {
        return url;
    }

    public HeaderRequest setUrl(String url) {
        this.url = url;
        return this;
    }

    public String getOs() {
        return os;
    }

    public HeaderRequest setOs(String os) {
        this.os = os;
        return this;
    }

    public String getWin() {
        return win;
    }

    public HeaderRequest setWin(String win) {
        this.win = win;
        return this;
    }

    public String getIe() {
        return ie;
    }

    public HeaderRequest setIe(String ie) {
        this.ie = ie;
        return this;
    }

    @Override
    public String toString() {
        try {
            return Marshall.getInstance().marshal(this, MarshallProperties.WITHOUT_XML_HEADER);
        } catch (Exception e) {
            return super.toString();
        }
    }

    public static void main(String...str) {
        System.out.println(new HeaderRequest()
                .setBaseUrl("")
                .setUrl("")
                .setOs("")
                .setWin("N")
                .setIe("N")
                .toString());
    }
}
